/*
 *  shobject.cpp
 *  shaderz_v3
 *
 *  Created by Anjali on 3/22/11.
 *  Copyright 2011 __MyCompanyName__. All rights reserved.
 *
 */

#include "shobject.h"

using namespace shaderz;

// constructor for the object
shObject::shObject()
{
}

shObject::~shObject()
{
}

void* shObject::operator new( size_t InSize )
{
	void* pNewObj = malloc( InSize );

	// record the allocation
	shMemoryTracker::registerMemoryAllocation( static_cast<shObject*>(pNewObj), InSize, false, "NoFileInfo", -1 );
	
	return pNewObj;
}

void shObject::operator delete( void* InObject )
{
	// remove the allocation record for this object
	shMemoryTracker::unRegisterMemoryAllocation( static_cast<shObject*>(InObject) );

	// finally free the memory and return
	free(InObject);
}

void* shObject::operator new[]( size_t InSizeToAllocate )
{
	void* pNewArray = malloc( InSizeToAllocate );

	// record the allocation
	shMemoryTracker::registerMemoryAllocation( static_cast<shObject*>(pNewArray), InSizeToAllocate, true, "NoFileInfo", -1 );
		
	return pNewArray;
}

void shObject::operator delete[]( void* InObject )
{
	// remove the allocation record for this object
	shMemoryTracker::unRegisterMemoryAllocation( static_cast<shObject*>(InObject) );
	
	// finally free the memory and return
	free(InObject);
}
